<template>
	<view class="container" v-if="orderDetail">
		<view class="cell_title">订单商品</view>
		<!-- start 列表 -->
		<view class="cell_content">
			<view class="celllist row" v-for="(item,index) in orderDetail.snap_items" :key="index">
				<view class="cell_img">
					<image :src="item.goods_info.image"></image>
				</view>
				<view class="cell_info">
					<view class="overflow-row cell_name">{{item.goods_info.name}}</view>
					<view class="overflow cell_fwb">{{item.goods_info.goods_naming.title}}</view>
					<view class="cell_price">
						<text>¥{{item.goods_info.goods_price}}</text>
						<text>x{{item.goods_num}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- end -->
		<view class="cancellbutton" @click="confirmOrder" v-if="orderDetail.order_state==3">
			确认核销
		</view>
	</view>
</template>

<script>
	var app = getApp();
	import http from "../../../common/js/request.js";
	import common from "../../../common/js/function.js";
	export default {
		data() {
			return {
				orderDetail: []
			}
		},
		onLoad(options) {
			var that = this;
			http.post('api/store/order/OrderInfo', {
				order_id: options.order_id
			}, res => {
				that.orderDetail = res.datas;
			});
		},
		methods: {
			confirmOrder() {
				var that = this;
				uni.showModal({
					title: '确认操作',
					content: '您确认核销此订单吗？',
					success(e) {
						if (e.confirm) {
							http.post('api/store/order/OrderCancel', {
								order_id: that.orderDetail.id
							}, res => {
								if (res.state == 1) {
									that.orderDetail.order_state = 4;
									uni.showModal({
										title: '成功',
										content: '订单核销成功~',
										showCancel: false,
										success(e) {
											if (e.confirm) {
												uni.navigateBack();
											}
										}
									});
								} else {
									uni.showToast({
										title: res.datas,
										icon: 'none'
									});
								}
							});
						}
					}
				});

			}
		}
	}
</script>

<style>
	@import url("../../../common/css/cancellation.css");
</style>
